// ValidationAspects
// Written by Mike Saunders
// Released under Microsoft Public License (Ms-PL)
using System;
using System.Reflection;
using NUnit.Framework;
using ValidationAspects;
using ValidationAspects.Sdk;

namespace TestValidationAspects.Unity
{
	public static class ValidationContextExtensions
	{
		public static void TestValues(this IValidationContext context, Type instanceType, PropertyInfo property, MethodBase method, ParameterInfo parameter, object[] methodArgs)
		{
			Enforce.IsNotNull(context, "context");

			Assert.AreSame(instanceType, context.Type, "type does not match");
			Assert.AreSame(property, context.Property, "property does not match");
			Assert.AreSame(method, context.Method, "method does not match");
			Assert.AreSame(parameter, context.Parameter, "parameter does not match");

			if (methodArgs == null)
			{
				Assert.IsNull(context.Arguments);
				return;
			}

			if (context.Arguments == null)
			{
				Assert.IsNull(methodArgs);
				return;
			}

			Assert.AreEqual(methodArgs.Length, context.Arguments.Length);

			for (int i = 0; i < methodArgs.Length; ++i)
			{
				Assert.AreEqual(methodArgs[i], context.Arguments[i]);
			}
		}
	}
}